<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'wage_toadd.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<link rel="stylesheet" type="text/css" href="css/emp_add.css">
<link rel="stylesheet" type="text/css" href="css/table.css">
<link href="css/sunny/jquery-ui-1.10.2.custom.css" rel="stylesheet">
<script src="js/jquery/jquery-1.9.1.js"></script>
<script src="js/jquery/jquery-ui-i18n.js"></script>
<script src="js/jquery/jquery-ui-1.10.2.custom.js"></script>
<script language="javascript" type="text/javascript"
	src="<%=basePath%>My97DatePicker/WdatePicker.js"></script>
<script>
	function Change_Select() {//当第一个下拉框的选项发生改变时调用该函数
		$.ajax({
			url : "employeeAction!listEmployeeByDeptId.action",
			data : {
				dept_id : $("#deptid").val()
			},
			success : function(data) {
				$("#emp_name").html(data);
			}
		});
	}
</script>
</head>

<body>
	<c:choose>
		<c:when test="${param.search!=null}">
			<sql:query var="result">
			select performance_id,performance_emp_name,performance_date,performance_treat_type,performance_treat_amount,performance_reason from t_performance where date_format(performance_date,'%Y-%m')=? and performance_emp_id=?
			<sql:param value="${param.performance_month}" />
			<sql:param value="${param.emp_id}"/>
			</sql:query>
			<table>
				<caption>工作表现记录</caption>
				<thead>
					<tr>
						<th>姓名</th>
						<th>时间</th>
						<th>类型</th>
						<th>数目</th>
						<th>原因</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody id="tab">
					<c:forEach var="row" items="${result.rows}">
						<tr>
								<td><c:out value="${row.performance_emp_name}" />
								</td>
								<td><c:out value="${row.performance_date}" />
								</td>
								<td><c:out value="${row.performance_treat_type}" />
								</td>
								<td><c:out value="${row.performance_treat_amount}" />
								</td>
								<td><c:out value="${row.performance_reason}" />
								</td>
								<td>
						<a href="performanceAction!delPerformance.action?performance.performance_id=${row.performance_id}">[删除]</a>
						<a href="performanceAction!showUpdatePerformance.action?performance.performance_id=${row.performance_id}">[修改]</a>
								</td>
						</tr>
					</c:forEach>
				</tbody>
			</table>
			<script type="text/javascript">
			<!--
				var Ptr = document.getElementById("tab").getElementsByTagName(
						"tr");
				function $() {
					for (i = 1; i < Ptr.length + 1; i++) {
						Ptr[i - 1].style.backgroundColor = (i % 2 > 0) ? "#fff"
								: "#eee";
					}
				}
				window.onload = $;
				for ( var i = 0; i < Ptr.length; i++) {
					Ptr[i].onmouseover = function() {
						this.tmpClass = this.className;
						this.style.backgroundColor = "#ccc";

					};
					Ptr[i].onmouseout = function() {
						for (i = 1; i < Ptr.length + 1; i++) {
							Ptr[i - 1].style.backgroundColor = (i % 2 > 0) ? "#eee"
									: "#fff";
						}
					}
				}
			//-->
			</script>
		</c:when>
		<c:otherwise>
			<h3>选择要查看的员工</h3>
			<div id="container">
				<form id="fm-form" method="post"
					action="admin/perfor_toread.jsp">
					<fieldset>
						<div class="fm-req">
							<label for="fm-firstname">部门</label> <select
								onChange="Change_Select()"  id="deptid">
								<sql:query var="result"
									sql="select dept_id,dept_name from t_department" />
								<!--第一个下拉菜单-->
								<option value="0">请选择</option>
								<c:forEach var="row" items="${result.rows}">
									<option value="${row.dept_id}">${row.dept_name}</option>
								</c:forEach>
							</select>
						</div>
						<div class="fm-req">
							<label for="fm-firstname">员工姓名</label> <select id="emp_name"
								name="emp_id"></select>
						</div>
						<div class="fm-req">
							<label for="fm-firstname">月份</label> <input
								name="performance_month"
								onclick="WdatePicker({dateFmt:'yyyy-MM'})" type="text" /> <input
								name="search" type="hidden" value="search" />
						</div>
					</fieldset>
					<div id="fm-submit" class="fm-req">
						<input name="Submit" value="&#25552; &#20132;" type="submit">
					</div>
					<br>
				</form>
			</div>
		</c:otherwise>
	</c:choose>

</body>
</html>
